"""
编写测试用例
"""
from selenium import webdriver
from  selenium.webdriver.common.by import By
from time import sleep

username_locator = (By.NAME, "name")
password_locator = (By.NAME, "password")
submit_locator = (By.NAME, 'submit')
rc_locator = (By.LINK_TEXT,"日程")
#清楚数据定位表格
tbody_locator = (By.CSS_SELECTOR,"#form1 > table > tbody")
delate_locator = (By.ID,"delete")

driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(30)
driver.get("http://192.168.1.55/crm")
username,password = "admin", "admin123"
driver.find_element(*username_locator).send_keys(username)
driver.find_element(*password_locator).send_keys(password)
driver.find_element(*submit_locator).click()

driver.find_element(*rc_locator).click()
tbody = driver.find_element(*tbody_locator)
trs = tbody.find_elements(By.TAG_NAME,"tr")
for i in trs:
    tds = i.find_elements(By.TAG_NAME,'td')
    if tds[1].text == '下午开会':
        tds[0].find_element(By.CSS_SELECTOR,'input[name="event_id[]"]').click()
        break
driver.find_element(*delate_locator).click()
driver.switch_to.alert.accept()



sleep(5)
driver.quit()
